<?php

namespace App\Models;


use Illuminate\Database\Eloquent\Model;

class FhResource extends Model
{
	
    protected $table = 'fh_resource';


    public static function boot()
    {
        parent::boot();

        // static::saving(function ($model) {
           
        //     $model->r_type = empty($model->r_type)? $model->n_type : $model->r_type;
        //     unset($model->n_type);
        // });
    }

    public function list()
    {
        return $this->hasMany('App\Models\FhResourseList','p_id','id');
    }

    public function delete()
    {
        // 删除关联的 Comment
        $this->list()->delete();

        // 删除 Blog 本身
        parent::delete();
    }
    
}
